<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	request.setCharacterEncoding("UTF-8");
	String htmlData = request.getParameter("content1") != null ? request.getParameter("content1") : "";
%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="<%=path%>/My97DatePicker/WdatePicker.js"></script>
<link rel="stylesheet" type="text/css" href="<%=path%>/CSS/backLayout.css">
</head>
<style>
.div_form{margin-left: 150px;margin-right: 150px;margin-top: 30px}
.table1 input{width: 150px}
.table1 tr td{text-align: center;color: #444444}
.table1 tr:nth-child(1) td{border-left:  1px solid #c3c4d1;border-right:1px solid #c3c4d1;border-top:1px solid #c3c4d1;font-size: 15px; }
.table1{border-spacing:0;}
</style>
<body style="background: #f5f5f5">
<div class="main">
	<div class="weizhi">
		报表>>财务报表>>国力大车日账表>>新增
	</div>
	<div class="div_body" style="box-shadow: 0 0 5px #cccccc;height: 1300px">
		<div class="div_form">
			<form action="<%=path%>/DrivingSys/addBigCarJournal" class="form">
					<table class="table1">
						<tr style="height: 55px;background: #e4eafe">
							<td width="150px">考试日期</td>
							<td width="150px">约考人数</td>
							<td width="150px">未到人数</td>
							<td width="150px">实考人数</td>
							<td width="150px">及格人数</td>
                            <td width="150px">及格率(%)</td>
							<td width="150px">本市考生实考人数</td>
							<td width="150px">备注</td>
						</tr>
						<c:forEach items="${bigCarJournals}" var="a">
						<tr>
							<td><input type="text" name="ksrq" value="${a.ksrq}" readonly="readonly"></td>
							<td><input type="text" name="ykrs" value="${a.ykrs}" onblur="ykrs2($(this))"></td>
                            <td><input type="text" name="wdrs" value="${a.wdrs}" onblur="wdrs2($(this))"></td>
							<td><input type="text" name="skrs" value="${a.skrs}" onblur="skrs2($(this))"></td>
							<td><input type="text" name="jgrs" value="${a.jgrs}" onblur="jgrs2($(this))"></td>
                            <td><input type="text" name="jgl" value="${a.jgl}" class="jgl" onblur="jgl2($(this))"></td>
                            <td><input type="text" name="bssk" value="${a.bssk}" onblur="bssk2($(this))" class="bssk">
                            </td>
							<td><input type="text" name="cfdesc" value="${a.cfdesc}" class="cfdesc"></td>
						</tr>
						</c:forEach>
					</table>
					
					<div class="div_tj" style="padding-top: 50px">
						<div>
                            <input class="input_submit bc" value="" type="submit">
						</div>
						<div>
                            <input type="button" class="input_back fh" value="" onclick="back()"/>
						</div>
					</div>
			</form>
		</div>
	</div>
</div>
</body>
<script type="text/javascript" src="<%=path%>/JQuery/jquery-1.8.2.js"></script>
<%@ include file="/WEB-INF/JSP/ajax.jsp"%>
<script type="text/javascript">
//只能输入正整数
$(".table1 input").live('keyup', function(event){
	var className = $(this).prop("class");	
	if(className == 'jgl' || className == 'cfdesc'){
		
	}else{
		if($(this).val() == '0'){
			
		}else{
			$(this).val($(this).val().replace(/\D|^0/g,''));  
		}
	}
});

//约考人数
function ykrs2(_this){
    //判断输入错误
    if (isNaN(Number(_this.val()))) {
        _this.val("")
    }
	//约考人数
	var ykrs = _this.val();
	//找到未到人数
	var wdrs = _this.parent().next().find("input").val();
	if(ykrs == null || ykrs == '' || wdrs == null || wdrs == ''){
		
	}else if(wdrs*1 > ykrs*1){
		alert("未到人数大于约考人数");
		_this.val("");
		return false
	}else{
		var skrs = ykrs*1 - wdrs*1;
		_this.parent().next().next().find("input").val(skrs);
	}
}	

//未到人数
function wdrs2(_this){
    //判断输入错误
    if (isNaN(Number(_this.val()))) {
        _this.val("")
    }
	//未到人数
	var wdrs = _this.val();
	//找到未到人数
	var ykrs = _this.parent().prev().find("input").val();
	if(ykrs == null || ykrs == '' || wdrs == null || wdrs == ''){
		
	}else if(wdrs*1 > ykrs*1){
		alert("未到人数大于约考人数");
		_this.val("");
		return false
	}else{
		var skrs = ykrs*1 - wdrs*1;
		_this.parent().next().find("input").val(skrs);
	}
}
	
//实考人数
function skrs2(_this){
    //判断输入错误
    if (isNaN(Number(_this.val()))) {
        _this.val("")
    }
	//实考人数
	var skrs = _this.val()
	//找到及格人数
	var jgrs = _this.parent().next().find("input").val();
	if(jgrs == null || jgrs == ''){
		
	}else if(skrs == null || skrs == '' || skrs == '0'){
        _this.parent().next().next().find("input").val("");
	}else if(skrs*1 < jgrs*1){
		alert("及格人数大于实考人数");
		_this.val("");
		return false
	}else{
		//算出及格率
		var jgl = (jgrs*1) / (skrs*1);
		jgl = decimal(jgl,2)
		jgl = jgl*100;
        _this.parent().next().next().find("input").val(jgl);
	}
}
	
//及格人数
function jgrs2(_this){
    //判断输入错误
    if (isNaN(Number(_this.val()))) {
        _this.val("")
    }
	//及格人数
	var jgrs = _this.val()
	//实考人数
	var skrs = _this.parent().prev().find("input").val();
	if(jgrs == null || jgrs == ''){
        _this.parent().next().find("input").val("");
	}else if(skrs == null || skrs == '' || skrs == '0'){
		_this.parent().next().find("input").val("");
	}else if(skrs*1 < jgrs*1){
		alert("及格人数大于实考人数");
		_this.val("");
		return false
	}else{
		//算出及格率
	 	var jgl = (jgrs*1) / (skrs*1);
		jgl = decimal(jgl,2)
		jgl = jgl*100;
        _this.parent().next().find("input").val(jgl);
	}
}

//及格率
function jgl2(_this) {
    //判断输入错误
    if (isNaN(Number(_this.val()))) {
        /**算出及格率**/
            //实考人数
        var skrs = _this.parent().prev().prev().find("input").val();
        //及格人数
        var jgrs = _this.parent().prev().find("input").val();
        if (skrs == null || skrs == '' || jgrs == null || jgrs == '') {
            _this.val("")
        } else {
            //算出及格率
            var jgl = (jgrs * 1) / (skrs * 1);
            jgl = decimal(jgl, 2)
            jgl = jgl * 100;
            _this.val(jgl)
        }
    }

}

//本市考生实考人数
function bssk2(_this) {
    //判断输入错误
    if (isNaN(Number(_this.val()))) {
        _this.val("")
    }
}

//num是要处理的数字  v为要保留的小数位数
function decimal(num,v){
	var vv = Math.pow(10,v);
	return Math.round(num*vv)/vv;
}

//只能输入数字和小数
$(".jgl").live('keyup', function (event) {
    //最后一位是小数点的话，移除
    var $amountInput = $(this);
    //响应鼠标事件，允许左右方向键移动
    event = window.event || event;
    if (event.keyCode == 37 | event.keyCode == 39) {
        return;
    }
    //先把非数字的都替换掉，除了数字和.
    $amountInput.val($amountInput.val().replace(/[^\-?\d.]/g, "").//只允许一个小数点
    replace(/^\./g, "").replace(/\.{2,}/g, ".").//只能输入小数点后两位
    replace(".", "$#$").replace(/\./g, "").replace("$#$", ".").replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'));
});

function back(){
	location = '<%=path%>/DrivingSys/queryBigCarJournal/look.action';
}
</script>
</html>